package com.qfmy.mystation.ui.activity;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;

import com.qfmy.mystation.ui.adapter.HorizontalVpAdapter;
import com.qfmy.mystation.bean.WallpaperBean;
import com.qfmy.mystation.databinding.ActivityPictureDetailBinding;

import java.util.ArrayList;

public class PictureDetailActivity extends AppCompatActivity {
    private ArrayList<WallpaperBean> wallpaperList;
    private ActivityPictureDetailBinding binding;

    @SuppressLint("UseSupportActionBar")
    @RequiresApi(api = Build.VERSION_CODES.N)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityPictureDetailBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        setTitleTransparent();  // 设置状态栏透明
        wallpaperList = (ArrayList<WallpaperBean>) getIntent().getBundleExtra("data").getSerializable("wallpaper");
        binding.vp.setAdapter(new HorizontalVpAdapter(this, wallpaperList));
    }

    @Override
    protected void onStart() {
        super.onStart();
        int position = getIntent().getIntExtra("position", 0);
        binding.vp.setCurrentItem(position, false);
    }

    private void setTitleTransparent() {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
    }
}